import React,{Suspense} from 'react'
import {Route,Routes,BrowserRouter,Navigate} from 'react-router-dom'
import route from './router/index.js'

import './App.css'

function App() {
    const home=(arr)=>{
    return arr&&arr.map((item,index)=>{
      return <Route key={index} path={item.path} element={item.element?<item.element></item.element>:<Navigate to={item.to}></Navigate>}>
        {
          item.children&&home(item.children)
        }
      </Route>
    })
  }
  return (
   <Suspense fallback={<div>路由加载中</div>}>
      <BrowserRouter>
        <Routes>
          {
            home(route)
          }
        </Routes>
      </BrowserRouter>
   </Suspense>
  )
}

export default App
